<template>
  <div class="user">
    <div class="header">
        <div class="icon">
            <van-image
                width="50px"
                height="50px"
                round
                :src="user.avatar"
            />
        </div>
        <div class="username"><span>{{ this.user.username }}</span> </div>
       
    </div>
    <div class="bar">
        <van-grid :column-num="3">
            <van-grid-item  icon="clock-o" text="历史记录" />
            <van-grid-item  icon="bookmark-o" text="我的收藏" @click="$router.push('/main/shoucang')"/>
            <van-grid-item  icon="thumb-circle-o" text="我的点赞" @click="$router.push('/main/dianzan')" />
        </van-grid>
    </div>
    <div class="abouts">
        <van-cell title="推荐分享" is-link title-style="text-align: left;"/>
        <van-cell title="意见反馈" is-link title-style="text-align: left;"/>
        <van-cell title="关于我们" is-link title-style="text-align: left;"/>
        <van-cell title="退出登录" is-link title-style="text-align: left;" @click="logout"/>
    </div>
  </div>
</template>

<script>
import myAxios from '@/interceptors';
export default {
    name: 'HMUser',
    methods:{
        logout(){
            localStorage.removeItem('token')
            this.$router.push('/')
        }
    },
    data() {
        return {
            user: {}
        }
    },
    created() {
        try{
            myAxios.get('/h5/user/currentUser').then(res=>{
                const {data:rows} = res
                this.$nextTick(()=>{
                    this.user = rows
                })
                

            })
        }catch(err){
            console.log(err)
            this.$router.push('/')
        }
       
    }
}
</script>

<style scoped>
    .user{
        background-color: #f5f5f5;
        height: 900px;
        padding: 10px;
        
    }
    .header{
        width: 100%;
        height: 100px;
        display: flex;
        align-items: center;
        justify-content: left;


        span{
            font-weight: bold;
        }

        .icon{
            width: 50px;
            height: 50px;
            margin-right: 20px;
           
        }
    }

    .bar{
        width: 100%;
        height: 86px;
        background-color: #fff;
    }

    .abouts{
        width: 100%;
        margin-top: 30px;
    }
</style>